extends Control

var intent:Intent 
var current_action: MonsterAction
@onready var icon = $VBoxContainer/Panel/Sprite2D
@onready var times = $VBoxContainer/HBoxContainer/Panel/Times
@onready var label = $VBoxContainer/Panel/Label

func update_intent(action:MonsterAction) -> void:
	current_action = action
	action.init_intent_value()
	intent = action.intent
	if not intent:
		hide()
		return
	icon.texture = intent.icon
	icon.visible = icon.texture != null
	intent.update_tooltip_text()
	label.text = str(intent.intext_text)
	show()


func update_intent_value(monster:Monster):
	if current_action.action_id == 0:
		var temp_intent: Intent = current_action.intent
		intent.value = Globals.get_final_damage(monster.state, Globals.player_state, temp_intent.value)
	if current_action.action_id == 1:
		var temp_intent: Intent = current_action.intent
		intent.value = Globals.get_final_shield(monster.state, temp_intent.value)
	if intent != null:
		intent.update_tooltip_text()
		label.text = str(intent.intext_text)

